﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TaxBusiness.Model;
using TaxBusiness.DAL;

namespace TaxBusiness.BLL
{
    public class BusinessTypeBLL
    {
        public List<Model.BusinessType> GetParent()
        {
            List<BusinessType> typeList = new List<BusinessType>();
            BusinessTypeDB typedb = new BusinessTypeDB();
            typeList.Add(
                new BusinessType { ID = -1, TypeName = "--请选择--" }
            );
            typeList.AddRange(typedb.GetType());
            return typeList;
        }

        public List<Model.BusinessType> GetChildrenAddAll(int parentID)
        {
            List<BusinessType> typeList = new List<BusinessType>();
            BusinessTypeDB typedb = new BusinessTypeDB();
            List<BusinessType> childrenList = new List<BusinessType>();
            childrenList = typedb.GetType(parentID);
            if (childrenList.Count > 0)
            {
                typeList.Add(
                    new BusinessType { ID = -1, TypeName = "--所有--" }
                );
                typeList.AddRange(childrenList);
            }
            return typeList;
        }

        public List<Model.BusinessType> GetChildren(int parentID)
        {
            List<BusinessType> typeList = new List<BusinessType>();
            BusinessTypeDB typedb = new BusinessTypeDB();
            typeList = typedb.GetType(parentID);
            return typeList;
        }

        public string[] GetTypeArray(int parentID)
        {
            List<BusinessType> typeList = new List<BusinessType>();
            List<string> TypeIDList = new List<string>();
            BusinessTypeDB typedb = new BusinessTypeDB();
            typeList = typedb.GetType(parentID);
            foreach(var typeid in typeList)
            {
                TypeIDList.Add(typeid.ID.ToString());
            }
            return TypeIDList.ToArray();
        }
    }
}
